package chattingroom;

import myClient.clientCore.CommandController;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan({"myClient", "protobuf"})
@SpringBootApplication

public class ClientApplication {

    public static void main(String[] args) {

        // 启动并初始化 Spring 环境及其各 Spring 组件
        ApplicationContext context = SpringApplication.run(ClientApplication.class, args);

        // 启动聊天客户端
        startChatClient(context);
    }

    //启动聊天客户端
    private static void startChatClient(ApplicationContext context) {

        CommandController commandClient = context.getBean(CommandController.class);
        commandClient.initCommandMap();
        try {
            commandClient.commandThreadRunning();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}